//
//  ZBBottomToolsView.m
//  送礼
//
//  Created by 华惠友 on 2017/9/19.
//  Copyright © 2017年 华惠友. All rights reserved.
//
#define RGBA(r, g, b, a)    [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height


#import "ZBBottomToolsView.h"

@implementation ZBBottomToolsView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = RGBA(0, 0, 0, 0.1);
        [self creatUI];
    }
    return self;
}

- (void)creatUI{
    
    
    for (NSInteger i = 0; i < self.imageArr.count; i++) {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setImage:[UIImage imageNamed:self.imageArr[i]] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(bottomClick:) forControlEvents:UIControlEventTouchUpInside];
        button.tag = 100+i;
        if (i == 0) {
            button.frame = CGRectMake(10, 10, 40, 40);
        } else{
            button.frame = CGRectMake((SCREEN_WIDTH-180)+(i-1) * 60, 10, 40, 40);
        }
        [self addSubview:button];
    }
}

- (void)bottomClick:(id)sender{
    UIButton *tagButton = (UIButton *)sender;
    if (self.buttonClick) {
        self.buttonClick(tagButton.tag, sender);
    }
}

- (NSArray *)imageArr{
    if (_imageArr == nil) {
        _imageArr = @[@"mg_room_btn_liao_h",@"mg_room_btn_liwu_h",@"mg_room_btn_fenxiang_h", @"heart3"];
    }
    return _imageArr;
}

@end
